package com.cms.exception.permission;

import com.cms.utils.AjaxResult;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 权限处理异常
 * @author Administrator
 */
@ControllerAdvice
public class NoPermissionException {

    @ResponseBody
    @ExceptionHandler(UnauthorizedException.class)
    public AjaxResult handleShiroException(Exception ex) {
        return AjaxResult.error("没有权限，请联系管理员授权");
    }
    @ResponseBody
    @ExceptionHandler(AuthorizationException.class)
    public AjaxResult AuthorizationException(Exception ex) {
        return AjaxResult.error("授权失败，请联系管理员重新授权");
    }

}
